﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="AddDeliverHr.aspx.cs" Inherits="ZX.WebApp.Crm.Deliver.AddDeliverHr" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
    <link rel="stylesheet" type="text/css" href="../../scripts/yui_2.9.0/build/container/assets/skins/sam/container.css" />
    <link rel="stylesheet" type="text/css" href="../../scripts/yui_2.9.0/build/button/assets/skins/sam/button.css" />
    <link rel="stylesheet" type="text/css" href="../../scripts/yui_2.9.0/build/layout/assets/skins/sam/layout.css" />
    <link rel="stylesheet" type="text/css" href="../../scripts/yui_2.9.0/build/resize/assets/skins/sam/resize.css" />
    <link rel="stylesheet" type="text/css" href="../../Scripts/yui_2.9.0/build/datatable/assets/skins/sam/datatable.css" />
    <link href="../../Styles/base.css" rel="stylesheet" type="text/css" />
    <script src="../../Scripts/jquery-1.6.min.js" type="text/javascript"></script>
    <script src="../../Scripts/jquery.json-2.2.js" type="text/javascript"></script>
    <script src="../../Scripts/Jquery.form.js" type="text/javascript"></script>
    <script src="../../Scripts/jquery.calendar.js" type="text/javascript"></script>
    <link href="../../Styles/default/calendar.css" rel="stylesheet" type="text/css" />
    <script src="../../Scripts/Jquery.form.js" type="text/javascript"></script>
    <script src="../../Scripts/CombinButton.js" type="text/javascript"></script>
    <script src="../../Scripts/extend.validate.js" type="text/javascript"></script>
    <script type="text/javascript" src="../../Scripts/yui_2.9.0/build/yahoo-dom-event/yahoo-dom-event.js"></script>
    <script type="text/javascript" src="../../Scripts/yui_2.9.0/build/element/element-min.js"></script>
    <script type="text/javascript" src="../../Scripts/yui_2.9.0/build/datasource/datasource-min.js"></script>
    <script type="text/javascript" src="../../Scripts/yui_2.9.0/build/json/json-min.js"></script>
    <script type="text/javascript" src="../../Scripts/yui_2.9.0/build/connection/connection-min.js"></script>
    <script type="text/javascript" src="../../Scripts/yui_2.9.0/build/get/get-min.js"></script>
    <script type="text/javascript" src="../../Scripts/yui_2.9.0/build/dragdrop/dragdrop-min.js"></script>
    <script type="text/javascript" src="../../Scripts/yui_2.9.0/build/datatable/datatable-min.js"></script>
    <script type="text/javascript" src="../../Scripts/yui_2.9.0/build/paginator/paginator-min.js"></script>
    <script type="text/javascript" src="../../scripts/yui_2.9.0/build/layout/layout-min.js"></script>
    <script type="text/javascript" src="../../scripts/yui_2.9.0/build/button/button-min.js"></script>
    <script type="text/javascript" src="../../scripts/yui_2.9.0/build/container/container-min.js"></script>
    <script type="text/javascript" src="../../scripts/yui_2.9.0/build/event-delegate/event-delegate-min.js"></script>
    <link href="../../Styles/extendTable.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
        #yui-dt7-th-StudentName-liner span, #yui-dt7-th-IDCard-liner span, #yui-dt7-th-Sex-liner span, #yui-dt7-th-Post-liner span, #yui-dt7-th-IsDecision-liner span, #yui-dt7-th-ArriveatTime-liner span, #yui-dt7-th-Age-liner span, #yui-dt7-th-Tel-liner span, #yui-dt7-th-Stature-liner span
        {
            color: Red;
        }
    </style>
</head>
<body class="yui-skin-sam">
    <form id="form1" runat="server">
    <div id="toolbar" style="margin-top: 12px; text-align: center;">
        <%if (Flag != "0" && strView == "")
          { %>
        <p id="returnBack" style="text-align: left">
            &nbsp; 退回原因：<span style="color: Red">*</span>&nbsp;
            <input type="text" id="backReason" title="不超过30个汉字" maxlength="30" style="width: 80%;" />
            <br />
        </p>
        <%} %>
        <button type="button" id="btnSave" name="btnSave">
            保存</button>
        <button type="button" id="btnQdnx" name="btnQdnx">
            保存</button>
        <button type="button" id="btnNxja" name="btnNxja">
            保存</button>
        <button type="button" id="btnMarket" name="btnMarket">
            保存</button>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <button type="button" id="btnClose" name="btnClose">
            退回上一级</button>
    </div>
    <div class="fieldForm" id="fieldForm">
        <div id="content">
            <h3>
                基本信息</h3>
            <table class="table1">
                <tr>
                    <th>
                        <span>交付单号</span>
                    </th>
                    <td colspan="3">
                        <asp:TextBox ID="Code" runat="server" Enabled="false" BackColor="#e7eaf4" Width="126"></asp:TextBox>
                    </td>
                    <th>
                        <span>申请日期</span>
                    </th>
                    <td>
                        <input type="text" id="DeliverDate" name="DeliverDate" runat="server" class="yui-date"
                            dtype="D" style="width: 150; background: #e7eaf4;" disabled="disabled" />
                    </td>
                </tr>
                <tr>
                    <th>
                        <span style="color: Red">*</span><span>订单号</span>
                    </th>
                    <td width="21%">
                        <input type="hidden" id="OrderProductID" name="OrderProductID" runat="server" />
                        <input type="text" id="txtOrderProductID" name="txtOrderProductID" runat="server"
                            disabled="disabled" style="width: 150" />
                        <button id="btnOrderProductID" name="20" onclick="change('1')" type="button" runat="server"
                            class="btnCheck">
                            选择</button>
                    </td>
                    <th>
                        <span>客户编码</span>
                    </th>
                    <td width="21%">
                        <input type="text" id="CustomerCode" runat="server" disabled="disabled" style="width: 150;
                            background: #e7eaf4;" />
                    </td>
                    <th>
                        <span>客户名称</span>
                    </th>
                    <td width="21%">
                        <input type="hidden" id="CustomerId" runat="server" />
                        <input type="text" id="CustomerName" runat="server" disabled="disabled" style="width: 150;
                            background: #e7eaf4;" />
                    </td>
                </tr>
                <tr>
                    <th>
                        <span>客户来源</span>
                    </th>
                    <td>
                        <input type="text" id="OrderTypeName" disabled="disabled" runat="server" style="width: 150;
                            background: #e7eaf4;" />
                    </td>
                    <th>
                        <span>主营产品</span>
                    </th>
                    <td>
                        <input type="text" id="CompanyProduct" runat="server" disabled="disabled" style="width: 150;
                            background: #e7eaf4;" />
                    </td>
                    <th>
                        <span>客户类型</span>
                    </th>
                    <td>
                        <input type="text" id="TypeName" runat="server" disabled="disabled" style="width: 150;
                            background: #e7eaf4;" />
                    </td>
                </tr>
                <tr>
                    <th>
                        <span>信息专员</span>
                    </th>
                    <td>
                        <input type="text" id="AddUserName" runat="server" disabled="disabled" style="width: 150;
                            background: #e7eaf4;" />
                    </td>
                    <th>
                        <span>行销顾问</span>
                    </th>
                    <td>
                        <input type="text" id="SaleaddName" runat="server" disabled="disabled" style="width: 150;
                            background: #e7eaf4;" />
                    </td>
                    <th>
                        <span>一推讲师</span>
                    </th>
                    <td>
                        <input type="hidden" id="NegotiateTeach" />
                        <input type="text" id="LectorName" runat="server" disabled="disabled" style="width: 150;
                            background: #e7eaf4;" />
                    </td>
                </tr>
                <tr>
                    <th>
                        <span style="color: Red">*</span><span>负责交付人</span>
                    </th>
                    <td>
                        <input type="hidden" id="ClassFrontServer" />
                        <input type="text" id="txtClassFrontServer" runat="server" disabled="disabled" style="width: 150" />
                        <button id="btnClassFrontServer" runat="server" name="Z" type="button" onclick="change('0')"
                            class="btnCheck">
                            选择</button>
                    </td>
                    <th>
                        <span>客户经理</span>
                    </th>
                    <td>
                        <input type="hidden" id="ClassServer" />
                        <input type="text" id="CustomerMgrName" runat="server" disabled="disabled" style="width: 150;
                            background: #e7eaf4;" />
                    </td>
                    <th>
                        <span style="color: Red">*</span><span>客户经理手机</span>
                    </th>
                    <td>
                        <input type="text" id="MgrTel" maxlength="20" runat="server" onkeyup="this.value=this.value.replace(/\D/g,'')"
                            onafterpaste="this.value=this.value.replace(/\D/g,'')" style="width: 150;" />
                    </td>
                </tr>
                <tr>
                    <th>
                        <span>业绩归属</span>
                    </th>
                    <td>
                        <input type="text" id="OrderDeptName" disabled="disabled" runat="server" style="width: 150;
                            background: #e7eaf4;" />
                    </td>
                    <th>
                        <span>决策人</span>
                    </th>
                    <td>
                        <input type="text" id="Decisionmaker" runat="server" disabled="disabled" style="width: 150;
                            background: #e7eaf4;" />
                    </td>
                    <th>
                        <span>决策人手机</span>
                    </th>
                    <td>
                        <input type="text" id="DecisionTel" runat="server" disabled="disabled" style="width: 150;
                            background: #e7eaf4;" />
                    </td>
                </tr>
                <tr>
                    <th>
                        <span>公司地址</span>
                    </th>
                    <td>
                        <input type="text" id="Address" disabled="disabled" runat="server" style="width: 150;
                            background: #e7eaf4;" />
                    </td>
                    <th>
                        <span style="color: Red">*</span><span>公司接洽人</span>
                    </th>
                    <td>
                        <input type="text" id="LinkMan" maxlength="20" runat="server" style="width: 150;" />
                    </td>
                    <th>
                        <span style="color: Red">*</span><span>接洽人手机</span>
                    </th>
                    <td>
                        <input type="text" id="LinkManTel" maxlength="20" onkeyup="this.value=this.value.replace(/\D/g,'')"
                            onafterpaste="this.value=this.value.replace(/\D/g,'')" runat="server" style="width: 150;" />
                    </td>
                </tr>
                <tr>
                    <th><span style="color: Red">*</span><span>公司邮箱</span></th>
                    <td colspan="3"><input type="text" onblur="isEmail(this.value)" id="txtEmail" title="用于接收学员周总结" maxlength="50" runat="server" style="width: 23%;" /><span class="span_font"> 用于接收学员周总结</span></td><th><span style="color: Red">*</span><span>期数</span></th><td>
                    <input type="hidden" id="Term" runat="server" />
                        <input type="text" id="txtTerm" runat="server" disabled="disabled" style="width: 150" />
                        <button id="btnTerm" runat="server" name="zTerm" type="button" onclick="change('2')"
                            class="btnCheck">
                            选择</button>
                    </td>
                </tr>
                <tr>
                <th>
                        <span>本期英才交付剩余人数</span>
                    </th>
                    <td>
                        <input type="text" id="txtHaveNum" runat="server" disabled="disabled" style="width: 150;
                            background: #e7eaf4;" />
                    </td>
                    <th>
                        <span>开始时间</span>
                    </th>
                    <td>
                        <input type="text" id="txtBeginDate" runat="server" disabled="disabled" style="width: 150;
                            background: #e7eaf4;" />
                    </td>
                    <th>
                        <span>结束时间</span>
                    </th>
                    <td>
                        <input type="text" id="txtEndDate" runat="server" disabled="disabled" style="width: 150;
                            background: #e7eaf4;" />
                    </td>
                </tr>
                <tr>
                    <th>
                        <span style="color: Red">*</span> <span>产品列表</span>
                    </th>
                    <td>
                        <input type="hidden" id="ProductId" runat="server" />
                        <asp:DropDownList ID="ProductList" runat="server" Width="140">
                        </asp:DropDownList>
                    </td>
                    <th>
                        <span>成交数量</span>
                    </th>
                    <td>
                        <input type="text" runat="server" id="Account" readonly="readonly" style="width: 150;
                            background: #e7eaf4;" />
                    </td>
                    <th>
                        <span>应缴款</span>
                    </th>
                    <td>
                        <input type="text" runat="server" id="Pay1" readonly="readonly" style="width: 150;
                            background: #e7eaf4;" />
                    </td>
                </tr>
                <tr>
                    <th>
                        <span>已缴款</span>
                    </th>
                    <td>
                        <input type="text" runat="server" id="Pay2" readonly="readonly" style="width: 150;
                            background: #e7eaf4;" />
                    </td>
                    <th>
                        <span>单价</span>
                    </th>
                    <td>
                        <input type="text" runat="server" id="Pay3" disabled="disabled" style="width: 150;
                            background: #e7eaf4;" />
                    </td>
                    <th>
                        <span>已交付数量</span>
                    </th>
                    <td>
                        <input type="text" id="PayAccount" readonly="readonly" style="width: 150; background: #e7eaf4;" /><input type="hidden" id="txtTjNum"/>
                    </td>
                </tr>
                <tr>
                    <th>
                        <span style="color: Red">*</span> <span>是否成交过鹰计划</span>
                    </th>
                    <td>
                        <asp:DropDownList ID="ddlSingle" runat="server" Width="140">
                            <asp:ListItem Value="">--请选择--</asp:ListItem>
                            <asp:ListItem Value="1">是</asp:ListItem>
                            <asp:ListItem Value="0">否</asp:ListItem>
                        </asp:DropDownList>
                    </td>
                    <th>
                        <span>备注</span>
                    </th>
                    <td>
                        <textarea rows="2" type="text" id="txtExplain" maxlength="100" title="不超过100个汉字"
                            runat="server" style="width: 130px" />
                    </td>
                    <th>
                        <span>填写人</span>
                    </th>
                    <td>
                        <input type="text" runat="server" id="txtXm" disabled="disabled" style="width: 150;
                            background: #e7eaf4;" />
                    </td>
                </tr>
            </table>
            <table class="table1" id="pm" style="display:none">
                <tr>
                    <td colspan="6">
                        &nbsp;
                    </td>
                </tr>
                <tr>
                    <th>
                        <span style="color: Red">*</span><span>班主任</span>
                    </th>
                    <td width="21%">
                        <input type="hidden" id="Memember" runat="server" />
                        <input type="text" id="txtMemember" runat="server" dtype="Z" disabled="disabled"
                            class="width70" />
                        <button id="btnMemember" name="R" type="button" runat="server" class="btnCheck">
                            选择</button>
                    </td>
                    <th>
                        <span style="color: Red">*</span><span>开课日期</span>
                    </th>
                    <td width="21%">
                        <input type="text" id="txtStartDate" runat="server" style="width: 150px;" />
                    </td>
                    <th>
                        <span style="color: Red">*</span><span>班主任手机</span>
                    </th>
                    <td width="21%">
                        <input type="text" id="txtGangerTel" maxlength="11" onkeyup="this.value=this.value.replace(/\D/g,'')"
                            onafterpaste="this.value=this.value.replace(/\D/g,'')" title="请填入正确的手机号码" runat="server"
                            style="width: 150px;" />
                    </td>
                </tr>
                <tr>
                    <th style="display:none">
                        <span>班级名称</span>
                    </th>
                    <td style="display:none">
                        <input type="text" id="txtClassNo" maxlength="30" title="不超过30个汉字" runat="server"
                            style="width: 150px;" />
                    </td>
                    <th>
                        <span>填写人</span>
                    </th>
                    <td>
                        <input type="hidden" id="AddUser" runat="server" />
                        <input type="text" runat="server" id="txtAddUser" disabled="disabled" style="width: 150px;
                            background: #e7eaf4;" />
                    </td>
                    <th>
                        <span>填写时间</span>
                    </th>
                    <td>
                        <input type="text" runat="server" id="txtAddTime" disabled="disabled" style="width: 150px;
                            background: #e7eaf4;" />
                    </td>
                </tr>
                <tr style="display: none;">
                    <td colspan="6">
                        &nbsp;
                    </td>
                </tr>
                <tr style="display: none;">
                    <td id="tdState1" style="display: none;">
                        &nbsp;状态：
                    </td>
                    <td id="tdState2" style="display: none;">
                        <asp:DropDownList ID="DliverState" runat="server" Width="159px">
                        </asp:DropDownList>
                    </td>
                    <td colspan="4">
                        &nbsp;
                    </td>
                </tr>
            </table>
            
        </div>
        <div class="extendDiv">
            <div id="con_two_1">
                <h3>
                    学员信息
                    <button type="button" id="btnNew1" name="btnNew1">
                        新增</button>
                    <button type="button" id="btnDelete1" name="btnDelete1">
                        删除</button>
                </h3>
                <div id="con_1">
                </div>
            </div>
             <table id="tbReturn" class="tableContent" style="width: 100%" border="1">
                <tr>
                    <td style="height: 16px;text-align:center" colspan="3">
                        <asp:GridView ID="gvworkflowMessage" CssClass="GridViewStyle" runat="server" AutoGenerateColumns="False"
                            Width="100%">
                            <Columns>
                                <asp:BoundField DataField="WorkFlowNo" HeaderText="流程编号">
                                    <ItemStyle Width="8%" />
                                </asp:BoundField>
                                <asp:BoundField DataField="TaskInstanceCaption" HeaderText="任务名称">
                                    <ItemStyle Width="10%" />
                                </asp:BoundField>
                                <asp:BoundField DataField="FlowCaption" HeaderText="流程名称">
                                    <ItemStyle Width="10%" />
                                </asp:BoundField>
                                <asp:BoundField DataField="OperatedDes" HeaderText="处理者">
                                    <ItemStyle Width="10%" />
                                </asp:BoundField>
                                <asp:BoundField DataFormatString="{0:yyyy-MM-dd HH:mm:ss}" HtmlEncode="False" DataField="taskEndTime"
                                    HeaderText="任务结束时间">
                                    <ItemStyle Width="10%" />
                                </asp:BoundField>
                                <asp:BoundField DataField="Message" HeaderText="审批意见">
                                    <ItemStyle Width="15%" />
                                </asp:BoundField>
                                <asp:BoundField DataField="SuccessMsg" HeaderText="状态">
                                    <ItemStyle Width="10%" />
                                </asp:BoundField>
                            </Columns>
                            <FooterStyle CssClass="FooterStyle" />
                            <RowStyle CssClass="RowStyle" />
                            <EmptyDataRowStyle CssClass="EmptyRowStyle" />
                            <PagerStyle CssClass="PagerStyle" />
                            <SelectedRowStyle CssClass="SelectedRowStyle" />
                            <HeaderStyle CssClass="HeaderStyle" />
                            <EditRowStyle CssClass="EditRowStyle" />
                            <AlternatingRowStyle CssClass="AltRowStyle" />
                        </asp:GridView>
                    </td>
                </tr></table>
        </div>
    </div>
    <div id="dialog1" class="yui-pe-content">
        <div class="hd">
            信息选择</div>
        <div class="bd">
            <iframe id="EditUIWindow1" frameborder="0" src="" style="width: 100%; height: 100%;
                margin: 0px; padding: 0px;"></iframe>
        </div>
    </div>
    <input type="hidden" id="ID" runat="server" />
    <input type="hidden" id="WorkFlowInsId" runat="server" />
    <input type="hidden" id="WorkTaskInsId" runat="server" />
    </form>
    <form id="form2" style="display: none" action="">
    <textarea style="display: none" id="jsonDataContent" rows="2" cols="2" name="jsonDataContent"></textarea>
    </form>
</body>
<script src="../../Scripts/Appjs/model.AddDeliverHr.js" type="text/javascript"></script>
<script type="text/javascript">
    var entity = "<% =EntityName %>",addUser="<%=addUser %>",
        action = "<% =DataAction %>",      HouseType=[<%=ListDetailHouseType %>],
        TrafficType=[<%=ListDetailTrafficType %>],
        MinZu=[<%=ListMinZu %>],  OperStatus="<%=strOperStatus %>",
        flag = "<%=Flag %>", strView="<%=strView %>",
        WorkFlowId="<%=strWorkFlowId %>",WorkTaskId="<%=strWorkTaskId %>",strOperStatus="<%=strOperStatus %>", strDescript="<%=strDescript %>",
        OperatorInstanceId="<%=strOperatorInstanceId %>",WorkflowInsId="<%=strWorkflowInsId %>",  WorkTaskInsId=$("#WorkTaskInsId").val(),
        ListRecord=[<%=ListRecord %>],vTeacher=[<%=Teacher %>]; 
        var Flag="<%=Flag %>";
    var CrmProduct = [<%=ListRecord %>];   
    var  DeliverMajorInfo = [<%=StrDeliverTrainInfo %>];
    var myDataSource1, mDataTable1;            
    var getTsid=$("#WorkTaskInsId").val();
    var vid = $("#ID").val();
    var btnSave = "",btnQdnx="",btnNxja="",btnClose = "",btnMarket="", condition = "",btnNews1="",btnDeletes1="";  
    <asp:Literal ID="EditTemplate" runat="server"></asp:Literal>
    (function () { 
//        if (strView!="check") {
//            var trs = $("#pm tr"); 
//             
//            if(strDescript=="qdnx"){
//                for (var i = 0; i < trs.length; i++) {
//                    if(i>=0&&i<=2){
//                        trs[i].style.display = "block";
//                    }else{
//                        trs[i].style.display = "none"; 
//                    }
//                }
//            }
//            else if(strDescript=="nxja"){
//                for (var i = 0; i < trs.length; i++) {
//                    if(i>=0&&i<=5){
//                        trs[i].style.display = "block";
//                    }else{
//                        trs[i].style.display = "none"; 
//                    }
//                }
//            }
//          
//            else{    
//                for (var i = 0; i < trs.length; i++) {
//                    trs[i].style.display = "none"; 
//                }
//            }      
//        }
        var Dom = YAHOO.util.Dom,Event = YAHOO.util.Event;
        Event.onDOMReady(function () {
            var layout = new YAHOO.widget.Layout({
                units: [
                { position: 'bottom', height: 90, body: 'toolbar', gutter: '1 1 1 1', scroll: null, zIndex: 2 },
                { position: 'center', body: 'fieldForm', gutter: '0 1 1 1', scroll: true }
                ]
            });
            layout.render();
        });
    })();
    YAHOO.example.init = function () {
    function onButtonClick(p_oEvent) {
        switch (this.get("id")) {
            case "btnSave":
                Save(0);
                break;
            case "btnClose":
                Close();
                break;
            case "btnQdnx":
                SaveQdnx();
                break;
            case "btnNxja":
                SaveNxja();
                break;
            case "btnMarket":
                SaveMarket();
                break;
            case "btnNew1": 
                handleAdd();
                break;
            case "btnDelete1":
                handleDelete();
                break;
            default:
                break;
        }
    }
    YAHOO.util.Event.onContentReady("toolbar", function () {
        btnSave = new YAHOO.widget.Button("btnSave");
        btnSave.on("click", onButtonClick);
        btnQdnx = new YAHOO.widget.Button("btnQdnx");
        btnQdnx.on("click", onButtonClick);
        btnNxja = new YAHOO.widget.Button("btnNxja");
        btnNxja.on("click", onButtonClick);
        btnMarket = new YAHOO.widget.Button("btnMarket");
        btnMarket.on("click", onButtonClick);
        btnClose = new YAHOO.widget.Button("btnClose");
        btnClose.on("click", onButtonClick);
        if (strView == "check") {
            btnQdnx._button.style.display = "none";
            $("#btnQdnx").attr('disabled', "true");
            btnNxja._button.style.display = "none";
            $("#btnNxja").attr('disabled', "true");
            btnMarket._button.style.display = "none";
            $("#btnMarket").attr('disabled', "true");
            btnClose._button.style.display = "none";
            $("#btnClose").attr('disabled', "true");
            btnSave._button.style.display = "none";
            $("#btnSave").attr('disabled', "true");
            LoadOrderProductInfo($("#OrderID").val());
        } 
        else if (queryString("statues") == 3) {
            btnQdnx._button.style.display = "none";
            $("#btnQdnx").attr('disabled', "true");
            btnNxja._button.style.display = "none";
            $("#btnNxja").attr('disabled', "true");
            btnMarket._button.style.display = "none";
            $("#btnMarket").attr('disabled', "true");
            btnClose._button.style.display = "none";
            $("#btnClose").attr('disabled', "true");
            btnSave._button.style.display = "none";
            $("#btnSave").attr('disabled', "true");
            LoadOrderProductInfo($("#OrderID").val());
        }
        else {
        if (strDescript=="zgsh") {
                  btnQdnx._button.style.display = "none";
                $("#btnQdnx").attr('disabled', "true");
                btnNxja._button.style.display = "none";
                $("#btnNxja").attr('disabled', "true");
                btnSave._button.style.display = "none";
                $("#btnSave").attr('disabled', "true");
                 LoadOrderProductInfo($("#OrderID").val());
}
          else  if (strDescript == "qdnx") {
                btnSave._button.style.display = "none";
                $("#btnSave").attr('disabled', "true");
                btnNxja._button.style.display = "none";
                $("#btnNxja").attr('disabled', "true");
                 LoadOrderProductInfo($("#OrderID").val());
                btnMarket._button.style.display = "none";
                $("#btnMarket").attr('disabled', "true");
            }
            else if (strDescript == "nxja") {
             LoadOrderProductInfo($("#OrderID").val());
                btnQdnx._button.style.display = "none";
                $("#btnQdnx").attr('disabled', "true");
                btnSave._button.style.display = "none";
                $("#btnSave").attr('disabled', "true");
                btnMarket._button.style.display = "none";
                $("#btnMarket").attr('disabled', "true");
            }
                 else { //新增时设置按钮隐藏
                btnQdnx._button.style.display = "none";
                $("#btnQdnx").attr('disabled', "true");
                btnNxja._button.style.display = "none";
                $("#btnNxja").attr('disabled', "true");
              btnMarket._button.style.display = "none";
                $("#btnMarket").attr('disabled', "true");
                btnClose._button.style.display = "none";
                $("#btnClose").attr('disabled', "true");
            }
        }
    });
   YAHOO.util.Event.onContentReady("con_two_1", function () {
        btnNews1 = new YAHOO.widget.Button("btnNew1");
        btnNews1.on("click", onButtonClick);
        btnDeletes1 = new YAHOO.widget.Button("btnDelete1");
        btnDeletes1.on("click", onButtonClick);
        if (strView == "check"|| strDescript == "qdnx" || strDescript == "nxja") {
            btnNews1._button.style.display = "none";
            $("#btnNews1").attr('disabled', "true");
            btnDeletes1._button.style.display = "none";
            $("#btnDeletes1").attr('disabled', "true");
            
        } LoadPayAccount($("#OrderProductID").val());
         
    });
}();

//只取一个URL参数：
        var queryString = function (key) {
            return (document.location.search.match(new RegExp("(?:^\\?|&)" + key + "=(.*?)(?=&|$)")) || ['', null])[1];
        }
//退回上一节点
var Close = function () {
    if ($("#backReason").val() == "") {
        alert("请填写退回原因");
        $("#backReason").focus();
        return;
    }
    var vMessage = $("#backReason").val();
    if (confirm("您确定退回?")) {
        var SaveUrl = "../../Extend/AjaxData/CustomOperating.aspx?r=" + Math.random() + "&action=check&entity=CrmDeliverHrUnAgree&msg=" + encodeURI(vMessage) + "" +
                "&OperatorInstanceId=" + OperatorInstanceId + "&WorkflowId=" + WorkFlowId + "&WorktaskId=" + WorkTaskId + "&WorkflowInsId=" + WorkflowInsId + "&WorktaskInsId=" + WorkTaskInsId + "";
        YAHOO.util.Connect.asyncRequest('POST', SaveUrl, {
            success: function (res) {
                try {
                    var str = res.responseText;
                    if (str == "1") {
                        window.location.href = "../../Crm/BasePages/tooltip.aspx?worktaskInstanceId=" + getTsid;
                    } else {
                        alert("数据保存失败!");
                        return;
                    }
                }
                catch (e) {
                }
                finally {
                }
            },
            failure: function (error) {
                alert("数据错误：" + error.statusText);
            }
        }, null);
    }
}
var csNum;
var change = function (obj) {
    csNum = obj
}

//选择对应的方法和ID
var _fn, _id;
function ShowDialog(fn, id, src) { 
    _fn = fn;
    _id = id;
    document.getElementById("EditUIWindow1").src = src;
    YAHOO.example.container.dialog1.show();
}
/* 对应的方法和ID*/
var _fn, _id;
function ShowDialog1(fn, id, src) {
    _fn = fn;
    _id = id;
    document.getElementById("EditUIWindow1").src = src;
    YAHOO.example.container.dialog1.show();
}


YAHOO.namespace("example.container");
YAHOO.util.Event.onDOMReady(function () {
    var handleSubmit = function () {
        var editwindow = document.getElementById("EditUIWindow1");
        if (editwindow) {
            editwindow.contentWindow.ChooseInfo();
            if (csNum == "1") { LoadOrderProductInfo(); }
            if (csNum == "2") { LoadTermInfo(); }
        }
        YAHOO.example.container.dialog1.hide();
    };
    var handleCancel = function () {
        this.cancel();
    };
    var handleSuccess = function (o) {
        var response = o.responseText;
        response = response.split("<!")[0];
        document.getElementById("resp").innerHTML = response;
    };
    var handleFailure = function (o) {
        alert("Submission failed: " + o.status);
    };
    YAHOO.example.container.dialog1 = new YAHOO.widget.Dialog("dialog1",
					            { width: "580px",
					                height: "450px",
					                fixedcenter: true,
					                visible: false,
					                draggable: true,
					                close: true,
					                autofillheight: "body",
					                constraintoviewport: true,
					                buttons: [{ text: "确定", handler: handleSubmit, isDefault: true },
								            { text: "取消", handler: handleCancel}]
					            });
    YAHOO.example.container.dialog1.callback = { success: handleSuccess, failure: handleFailure };
    YAHOO.example.container.dialog1.render();
});
//根据ID获取期数信息
var LoadTermInfo = function () {
    var vCId = "ID='" + $("#Term").val() + "'";
    YAHOO.util.Connect.asyncRequest('GET', "../../Extend/AjaxData/JSONList.aspx?r=" + Math.random() + "&type=1&entity=V_CrmDeliverHrTerm&customCondition=" + vCId + "",
    { success: function (res) {
        try {
            var str = res.responseText;
            var arr = [];
            var obj = eval(str);
            $('#txtHaveNum').val(obj[0].TermNum-obj[0].TermExistNum);
            $('#txtBeginDate').val(obj[0].StartTime);
            $('#txtEndDate').val(obj[0].EndTime);
            $('#Term').val(obj[0].ID);
        } catch (e) {
        }
        finally {
        }
    }, failure: function () { }
    });
}
//根据订单产品ID获取订单信息
var LoadOrderInfo = function () {
    var vCId = "ID='" + $("#OrderID").val() + "'";
    YAHOO.util.Connect.asyncRequest('GET', "../../Extend/AjaxData/JSONList.aspx?r=" + Math.random() + "&type=1&entity=V_CrmCustomerInfoDeliver&customCondition=" + vCId + "",
    { success: function (res) {
        try {
            var str = res.responseText;
            var arr = [];
            var obj = eval(str);
            $('#CustomerId').val(obj[0].CustomerId);
            $('#CustomerName').val(obj[0].CustomerName);
            $('#CustomerSource').val(obj[0].OriginName);
            $('#Account').val("");
            $('#Pay1').val("");
            $('#Pay2').val("");
            $('#Pay3').val("");
            document.getElementById("ProductList").options.length = 0;
            LoadOrderProductInfo(obj[0].ID);
        } catch (e) {
        }
        finally {
        }
    }, failure: function () { }
    });
}
var tempProduct = "";

var LoadOrderProductInfo = function (OrderId) {  
    var vCId = "OrderCode='" + $("#txtOrderProductID").val() + "'";
    YAHOO.util.Connect.asyncRequest('GET', "../../Extend/AjaxData/JSONList.aspx?r=" + Math.random() + "&type=1&entity=V_DeliverOrderProduct&customCondition=" + vCId + "", //条件 
            {success: function (res) {
                try {
                    var str = res.responseText;
                    var arr = []; var entity = {};
                    var obj = eval(str);
                    $('#CustomerCode').val(obj[0].CustomerCode);
                    $('#CustomerId').val(obj[0].CustomerId);
                    $('#CustomerName').val(obj[0].CustomerName);
                    $('#OrderTypeName').val(obj[0].CustomerOrigin);
                    $('#CompanyProduct').val(obj[0].CompanyProduct);
                    $('#TypeName').val(obj[0].CustomerType);
                    $('#AddUserName').val(obj[0].CInfoer);
                    $('#SaleaddName').val(obj[0].CSaler);
                    $('#CustomerMgrName').val(obj[0].CManager);
                    $('#LectorName').val(obj[0].CTeacher);
                    $('#Address').val(obj[0].Address);
                    $('#DecisionTel').val(obj[0].DecisionTel);
                    $('#Decisionmaker').val(obj[0].Decisionmaker);
                    $('#OrderDeptName').val(obj[0].OrderDeptName);
            tempProduct = obj;
            document.getElementById("ProductList").options.length = 0;
            $("#ProductList").append("<option value=''> </option>");
            var vOrderProductId = $("#txtOrderProductID").val();
            for (var i = 0; i < obj.length; i++) {               
                if (vOrderProductId == obj[i].OrderCode&&(obj[i].ProductId=="b387b0e6-1ab8-4c93-96aa-814cc2d12fb3"||obj[i].ProductId=="0a9aac1a-a18f-4d00-9d3e-deb74bbf1e22")) {   setControlDisabled(1);
                    $("#ProductId").val(obj[i].ProductId);
                    $("#ProductList").append("<option value='" + obj[i].ID + "' selected>" + obj[i].ProductName + "</option>");//加载已交付数量
                    LoadPayAccount(obj[i].ID);
                    $('#Account').val(tempProduct[i].Amount);
                    $('#Pay1').val(tempProduct[i].AccountReceivable);
                    $('#Pay2').val(tempProduct[i].ResignMoney);
                    //判断订单号的英才缴款是否缴款完成
                    var allMoney="<%=StrAllMoney %>";
                    if(allMoney==1&&Flag != "1"){
                    if (parseInt($('#Pay1').val())>parseInt($('#Pay2').val())) {
                        alert("该订单号的英才产品未完全缴款，不能提交");
                        location.reload(false);
                    }}
                    if(tempProduct[i].Amount==0){
                       $('#Pay3').val("0");
                    }else{
                       $('#Pay3').val(tempProduct[i].AccountReceivable/tempProduct[i].Amount);
                    }
                } else {
                    //$("#ProductList").append("<option value='" + obj[i].ID + "'>" + obj[i].ProductName + "</option>");
                }
            }
        }
        catch (e) {
        }
        finally {
        }
    }, failure: function () { }
    });
}
if (typeof ($) != "undefined") {
    $(document).ready(function () {
        $('#ProductList').change(function () {
            var OptionValue = $(this).children('option:selected').val();
            if (OptionValue != "") {
                for (var i = 0; i < tempProduct.length; i++) {
                    if (tempProduct[i].ID == OptionValue) {
                        //$("#OrderProductID").val(tempProduct[i].ID);
                        $("#ProductId").val(tempProduct[i].ProductId);
                        $('#Account').val(tempProduct[i].Amount);
                        $('#Pay1').val(tempProduct[i].AccountReceivable);
                        $('#Pay2').val(tempProduct[i].ResignMoney);
                        if(tempProduct[i].Amount==0){
                            $('#Pay3').val("0");
                            }else{
                              $('#Pay3').val(tempProduct[i].AccountReceivable/tempProduct[i].Amount); 
                            }

                        //加载已交付数量
                        LoadPayAccount(tempProduct[i].ID);
                    }
                }
            } else {$("#txtTjNum").val("");
            $('#PayAccount').val("");
                $('#Account').val("");
                $('#Pay1').val("");
                $('#Pay2').val("");
                $('#Pay3').val("");
            }
        });
        
    })
}
//加载已交付数量
var LoadPayAccount = function (OrderProductId) {
    var SaveUrl = "../../Extend/AjaxData/CustomOperating.aspx?r=" + Math.random() + "&action=check&entity=CrmDeliverHrPayAccount&id=" + OrderProductId;
    YAHOO.util.Connect.asyncRequest('POST', SaveUrl, {
        success: function (res) {
            try {
                var str = res.responseText;
                if (str == "00") {
                    //alert("加载已交付数量异常!");
                    //return;
                } else {
                    if (str.indexOf(',')>0) {
                    $("#PayAccount").val(str.split(',')[0]);
                    $("#txtTjNum").val(str.split(',')[1]);
                }
                    
                }
            }
            catch (e) {
            }
            finally {
            }
        },
        failure: function (error) {
            alert("数据错误：" + error.statusText);
        }
    }, null);
}

//保存英才学校人员
    var SaveQdnx=function(){ 
    if ($("#backReason").val() != "") {
        alert("保存时不要填写退回原因");
        $("#backReason").focus();
        return;
    }
    $("#DliverState").get(0).selectedIndex =1; 
        setQdnxValue();
         var orderid="<%=strOrderId %>",productid="<%=strProductId %>";
        if(strOperStatus!="1"){
        if(instance[0].PMemember==null||instance[0].PMemember=="") {
//            alert("班主任不能为空!");
//            $("#Memember").focus();
//            return;
        }
        if(instance[0].BeginDate==null||instance[0].BeginDate=="") {
//            alert("开课日期不能为空!");
//            $("#txtStartDate").focus();
//            return;
        }
       if($("#txtClassNo").val()=="") {
//            alert("班级名称不能为空!");
//            return;
        }
        }else{  
           /*var tempBd="<%=strStartDate %>",tempPmb="<%=strMemember %>",tempEpx="<%=strExplain %>" ;              
            instance[0].BeginDate=tempBd; 
            instance[0].PMemember=tempPmb; 
            instance[0].PExplain=tempEpx;*/ 
        } 
        var list = mDataTable1.getRecordSet()._records;                          
        var url = "../../Extend/AjaxData/CustomOperating.aspx?action=update&stateId="+$("#DliverState").val()+"&classNo="+encodeURI($("#txtClassNo").val())+"&num="+list.length+"&orderid="+orderid+"&productid="+productid+"&view="+strOperStatus+"&BeginDate="+instance[0].BeginDate+"&GangerTel="+instance[0].GangerTel+"&PMemember="+instance[0].PMemember+"&PExplain=&ApplicantUser="+instance[0].ApplicantUser+"&ApplicantDate="+instance[0].ApplicantDate+"&flag=1&entity="+entity+"&id=" + vid + "&oid=" + OperatorInstanceId + "&tid=" + WorkflowInsId;
        var formObject = document.getElementById('form2');
        YAHOO.util.Connect.setForm(formObject);
        
        setTimeout(function () {
                    var btn = document.getElementById("btnQdnx");
                    btn.disabled = true;
                    var cObj = YAHOO.util.Connect.asyncRequest('POST', url, callback);
                    setTimeout(function () { btn.disabled = false }, 10000);
                }, 10);
    }
 var setQdnxValue=function(){       
       instance[0].BeginDate=$("#txtStartDate").val();
       instance[0].PMemember=$("#Memember").val();
       instance[0].GangerTel=$("#txtGangerTel").val();
       instance[0].ApplicantUser=$("#AddUser").val();
       instance[0].ApplicantDate=$("#txtAddTime").val();
    }
//保存
var Save = function (obj) {
    if($("#txtHaveNum").val()<=0){
        alert("该期人数已爆满!");
        return;
    }
    if($("#txtTjNum").val()==parseInt($("#Account").val())){
        alert("提交人数已满!");
        return;
    }
    $("#DliverState").get(0).selectedIndex = 2;
    setValue();         
    if ( $('#txtOrderProductID').val() == "" ) {
        alert("订单号不能为空!");
        $("#txtOrderProductID").focus();
        return;
    }
    if (instance[0].ClassFrontServer == null || instance[0].ClassFrontServer == "") {
        if (strView == "unDone") { instance[0].ClassFrontServer = "00000000-0000-0000-0000-000000000000"; }
        else {
            alert("负责交付人不能为空!");
            return;
        } 
    }
    if ( $('#MgrTel').val() == "" ) {
        alert("客户经理手机号码不能为空!");
        $("#MgrTel").focus();
        return;
    }
    if ( $('#LinkMan').val() == "" ) {
        alert("接洽人不能为空!");
        $("#LinkMan").focus();
        return;
    }
    if ( $('#LinkManTel').val() == "" ) {
        alert("接洽人手机号码不能为空!");
        $("#LinkManTel").focus();
        return;
    }
    if($("#txtEmail").val()=="") {
            alert("公司邮箱不能为空!");
            $("#txtEmail").focus();
            return;
    }
    if ($("#txtTerm").val() == "") {      
            alert("期数不能为空!");
            $("#txtTerm").focus();
            return;
    }
    if ($("#ProductId").val() == "") {      
            alert("产品列表不能为空!");
            $("#ProductId").focus();
            return;
    }
    if ($("#ddlSingle").val() == "") {      
            alert("请填写是否参加了鹰计划!");
            $("#ddlSingle").focus();
            return;
    }
    var list = mDataTable1.getRecordSet()._records;
    var elist = [];
    instance[0].StudentList = "";
    for (var i = 0; i < list.length; i++) {
        if (list[i]._oData.MajorStudentID == "" || list[i]._oData.MajorStudentID == null) {
            list[i]._oData.MajorStudentID = "00000000-0000-0000-0000-000000000000";
        }
        if (list[i]._oData.StudentName == "" || list[i]._oData.StudentName == null) {
            alert("第" + (i + 1) + "行 学员名称不能为空!");
            return;
        }
        if (list[i]._oData.IDCard == "" || list[i]._oData.IDCard == null) {
            alert("第" + (i + 1) + "行 身份证号不能为空!");
            return;
            //list[i]._oData.IDCard = "";
        }
        if (list[i]._oData.Sex == "" || list[i]._oData.Sex == "00" || list[i]._oData.Sex == null) {
            alert("第" + (i + 1) + "行 性别不能为空!");
            return;
        }
        if (list[i]._oData.Post == "" || list[i]._oData.Post == null) {
            alert("第" + (i + 1) + "行 职务不能为空!");
            return;
        }
        if (list[i]._oData.IsDecision == "" || list[i]._oData.IsDecision == "00" || list[i]._oData.IsDecision == null) {
            alert("第" + (i + 1) + "行 是否是决策人不能为空!");
            return;
        }
        if (list[i]._oData.ArriveatTime == "" || list[i]._oData.ArriveatTime == null) {
            alert("第" + (i + 1) + "行 到达日期不能为空!");
            return;
        }
        if (list[i]._oData.Age == "" || list[i]._oData.Age == null) {
            alert("第" + (i + 1) + "行 年龄不能为空!");
            return;
        }
        if (list[i]._oData.Tel == "" || list[i]._oData.Tel == null) {
            alert("第" + (i + 1) + "行 手机不能为空!");
            return;
        }
        if (list[i]._oData.Stature == "") {
            alert("第" + (i + 1) + "行 身高不能为空!");
            return;
        }
        elist.push(list[i]._oData);
        elist[i].MajorID = $('#ID').val();
    }
    for (var j = 0; j < elist.length; j++) {
        var vCustomerId = $("#CustomerId").val();
        if (vCustomerId == "") {
            vCustomerId = "00000000-0000-0000-0000-000000000000";
        }
        instance[0].StudentList += "#" + vCustomerId + "︾" + elist[j].MajorStudentID + "︾"+ $("#ID").val() + "︾" +
                                   elist[j].StudentName + "︾" + elist[j].IDCard + "︾" +
                                   elist[j].Sex + "︾" + elist[j].Post + "︾" + elist[j].IsDecision + "︾" +
                                   elist[j].ArriveatTime + "︾" +  elist[j].Age + "︾" + elist[j].Tel + "︾" + elist[j].Stature + "︾";
    }
   
    //        else{
    //            if(instance[0].ClassFrontServer == null || instance[0].ClassFrontServer ==  ""){
    //                alert("请修改负责交付人!");
    //                return;
    //            }  
    //        }
    var json = $.toJSON(instance[0]).replace(/'/g, "[B]");
    $("#jsonDataContent").val(json);
    setTimeout(function () {
                    var btn = document.getElementById("btnSave");
                    btn.disabled = true;
                     trySave();
                    setTimeout(function () { btn.disabled = false }, 10000);
                }, 10);
 
}
var setValue = function () {
    instance[0].ID = $("#ID").val();
    instance[0].Code = $("#Code").val();
    instance[0].DliverState = $("#DliverState").val();
    instance[0].ClassFrontServer = $("#ClassFrontServer").val();
    instance[0].WorkFlowId = WorkFlowId;
    instance[0].WorkTaskId = WorkTaskId;
    instance[0].Email = $("#txtEmail").val();
    instance[0].Explain=$("#txtExplain").val();     
    instance[0].WorkFlowInsId = $("#WorkFlowInsId").val();
    instance[0].WorkTaskInsId = $("#WorkTaskInsId").val();  
    instance[0].IsDealEP=  $("#ddlSingle").val();  
    instance[0].TermId=$("#Term").val();
}
function trySave() {
    var url = "../../Extend/AjaxData/CustomOperating.aspx?action=" + action + "&orderPid="+$("#OrderProductID").val()+"&productId="+$("#ProductId").val()+"&linkman=" + encodeURI($("#LinkMan").val()) + "&linkmanTel=" + encodeURI($("#LinkManTel").val()) + "&mgrTel=" + encodeURI($("#MgrTel").val()) + "&cName=" + encodeURI($("#CustomerName").val()) + "&view=" + strView + "&flag=1&entity=" + entity + "";
    var formObject = document.getElementById('form2');
    YAHOO.util.Connect.setForm(formObject);            
    var cObj = YAHOO.util.Connect.asyncRequest('POST', url, callback); 
}
 //资格审核
    var SaveMarket=function(){ 
    if ($("#backReason").val() != "") {
        alert("保存时不要填写退回原因");
        $("#backReason").focus();
        return;
    }
    $("#DliverState").get(0).selectedIndex = 6;     
         var url = "../../Extend/AjaxData/CustomOperating.aspx?action=update&flag =1&stateId="+$("#DliverState").val()+"&id=" + vid + "&flag=1&entity=CrmDeliverHrZgsh&oid=" + OperatorInstanceId;
            var formObject = document.getElementById('form2');
            YAHOO.util.Connect.setForm(formObject);
            setTimeout(function () {
                    var btn = document.getElementById("btnMarket");
                    btn.disabled = true;
                    var cObj = YAHOO.util.Connect.asyncRequest('POST', url, callback);
                    setTimeout(function () { btn.disabled = false }, 10000);
                }, 10);           
    }
 var responseSuccess = function (res) {
        try {                    
            var str = res.responseText;
            if (str == "1") { 
                RefreshDataParent();
                window.location.href = "../../Crm/BasePages/tooltip.aspx?worktaskInstanceId=" + getTsid;
            }
            else {
                alert(str);
            }
        } catch (e) {
        }
        finally {
        }
    }

    var responseFailure = function (error) {
        alert("数据错误：" + error.statusText);
    }

    var callback = {
        success: responseSuccess,
        failure: responseFailure
    };
     //刷新父窗体数据
    function RefreshDataParent() {
        if (parent.NeedRefreshPage != null) {
            if (typeof (parent.NeedRefreshPage.LoadData) == "function") {
                parent.NeedRefreshPage.RefreshData();
            }
        }
    }
    var setControlDisabled = function (obj) {
    if (obj == 1) {
       
        var obj = document.getElementById("fieldForm"); //得到DIV对象
        var s = obj.getElementsByTagName("select");
      
        for (var j = 0; j < s.length; j++) {
           // s[j].disabled = true;
        }
    }
}
    //邮箱验证
    function isEmail(val) {
        if (val != "") {
            var myreg = /^([a-zA-Z0-9]+[_|\-|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,4}$/;
            if (!myreg.test(val)) {
                alert("邮箱格式不合法!");
                $('#txtEmail').focus();
                document.getElementById("txtEmail").value = "";
                return;
            }
        }
    }
$(document).ready(function () {  LoadOrderProductInfo("");
    $('#txtStartDate').cld();      
    $('#txtEndTime').cld();
    
    //$('#DeliverDate').cld();
});
</script>
</html>
